<template>
	<view v-if="pageshow">
		
	 <view class="content">
		 <u-line color="#F1F1F1" />
		 <block v-for="(item,index) in list" :key="index" v-if="list.length>0">
		   <tie :item="item.tie"></tie>
		 </block>
		 
		 <u-loadmore v-if="!nodata" :load-text="loadText" :status="status" icon-type="flower" margin-top="20"
		 	margin-bottom="20" />
		<u-empty text=" 暂无数据" mode="list" v-if="nodata"></u-empty>
	 </view>
  <foot></foot>
  <auth :isauth="check_auth"></auth>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				cid:0,
				status: 'loadmore',
				page: 1,
				nodata: false,
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				pageshow: false,
				list: [],
				current: 0
			}
		},
		
		onReachBottom() {
			if (this.status != 'loadmore') {
				return;
			}
			this.status = "loading"
			this.page++;
			this.item_list()
		},
		onPullDownRefresh() {
		
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		async onLoad(e) {
			// #ifdef MP
			if (!this.user.id){
				 let a=await this.wxlogin()
				 this.user=uni.getStorageSync("user")
			}
			// #endif
			if (e.cid){
				this.cid=e.cid
				this.changecurren(this.cid);
			}
			
			this.item_list()
			
		},
		methods: {
			async changecurren(cid){
				if (!this.webset.tie_types){
					let a=await this.$store.dispatch('doset',this.$u)
				}
				
				let temp=this.webset.tie_types
				this.current=temp.findIndex((value)=>value.id==this.cid);
			},
             change(index) {
				 this.nodata=false;
             	this.current = index;
				this.status = "loading"
				this.page=1;
				this.item_list()
				
             },
			 item_list() {
			 	this.$u.post('index.php?mod=app&act=list&table=fav', {
			 		limit: 6,
					uid:uni.getStorageSync("uid"),
			 		page: this.page
			 	}).then(res => {
			 		this.pageshow = true
			 		this.active = false
			 		let total = res.count
			 		this.count = res.count
			 		if (this.page == 1)
			 			this.list = res.data
			 		else
			 			this.list = this.list.concat(res.data)
			       
			 		if (total == this.list.length) {
			 
			 			if (this.list.length == 0) {
			 				this.nodata = true
			 			} else
			 				this.status = "nomore"
			 			//this.loadText.nomore = (this.total > res.pagesize) ? "实在没有了" : ""
			 		} else {
			 			this.status = "loadmore"
			 		}
			 
			 	});
			 },
		}
	}
</script>

<style>

</style>
